package com.xcjh.opencv.rule.yidui;

import com.xcjh.opencv.ExeRule;
import com.xcjh.opencv.ImageUtil;
import com.xcjh.opencv.emuns.MatchImage;
import com.xcjh.opencv.rule.BaseRule;
import org.opencv.core.Core;
import org.springframework.stereotype.Component;

import java.awt.*;

@Component
public class Yidui implements BaseRule {
    @Override
    public String getRuleName() {
        return "伊对";
    }

    @Override
    public void run(Robot robot) throws Exception {
        findAndClickPic(MatchImage.伊对不去了, robot);
        if(findAndClickPic(MatchImage.伊对打招呼, robot)){
            ExeRule.delayByRobot(1000,robot);
        }else{
            findAndClickPic(MatchImage.伊对不去了, robot);
            //如果找不到打招呼,能找到发消息,说明走错地方了. 需要退出
            Core.MinMaxLocResult sendMsg = ImageUtil.findImage(MatchImage.伊对发消息, robot);
            if(sendMsg!=null){
                ExeRule.moveToByRobot(712, 156, robot);
                ExeRule.delayByRobot(50,robot);
                ExeRule.leftClickByRobot(1,robot);
            }
            ExeRule.mouseWheelByRobot(1,robot);
            ExeRule.delayByRobot(200,robot);
        }

    }
}
